package com.huike.web.controller.report;


import com.huike.common.utils.DateUtils;
import com.huike.report.domain.vo.BusinessServiceVO;
import com.huike.report.domain.vo.IndexTodayInfoVO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

import java.util.List;


@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }

    /**
     * 首页--今日简报
     * @return
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo(){
        String nowTime = DateUtils.getDate();
        IndexTodayInfoVO indexTodayInfoVO = reportService.getTodayInfo(nowTime);
        return AjaxResult.success(indexTodayInfoVO);
    }

    /**
     * 首页--待办事宜
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getTodoInfo(beginCreateTime, endCreateTime));
    }

    /**
     * 首页--商机转化龙虎榜
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(@RequestParam("beginCreateTime") String beginCreateTime,
                                               @RequestParam("endCreateTime") String endCreateTime){
        List<BusinessServiceVO>  businessServiceVO= reportService.businessChangeStatistics(beginCreateTime,endCreateTime);
        return AjaxResult.success(businessServiceVO);
    }
    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistic(@RequestParam("beginCreateTime") String beginCreateTime,
                                               @RequestParam("endCreateTime") String endCreateTime){
        List<BusinessServiceVO> businessServiceVO= reportService.salesStatistic(beginCreateTime,endCreateTime);
        return AjaxResult.success(businessServiceVO);
    }



}